from user.models import User
from django.contrib.auth.hashers import check_password

# 检查测试用户
test_phone = '13800138000'
user = User.objects.filter(phone=test_phone).first()

if user:
    print(f"找到用户: {user.username}")
    print(f"手机号: {user.phone}")
    print(f"密码哈希: {user.password_hash}")
    print(f"状态: {user.status}")
    print(f"角色: {user.role}")
    
    # 检查密码
    is_valid = check_password('123456', user.password_hash)
    print(f"密码验证: {is_valid}")
    
    # 尝试明文密码比较
    is_plaintext = user.password_hash == '123456'
    print(f"明文密码比较: {is_plaintext}")
else:
    print("用户不存在")
    
# 列出所有用户
print("\n所有用户:")
for u in User.objects.all()[:5]:
    print(f"- {u.username} ({u.phone})")
